<?php
namespace App\Api\Movie;

use PhalApi\Api;
use App\Domain\Movie\MovieList as MovieListDomain;
/**
 * 电影接口
 */
class MovieList extends Api
{
    public function getRules()
    {
        return array(
            'getList' => array(
                'limit'=>array('name'=>'limit','require'=>false),
                'page'=>array('name'=>'page','require'=>false)
            ),
            'getHome' => array(
            ),
            'getMovieInfo' => array(
                'source_id'=>array('name'=>'source_id','require'=>true)
            ),
            'searchList' => array(
                'title'=>array('name' => 'title', 'require' => false),
                'limit'=>array('name'=>'limit','require'=>false),
                'page'=>array('name'=>'page','require'=>false)
            ),
            'searchMovieList' => array(
                'title'=>array('name' => 'title', 'require' => false),
                'limit'=>array('name'=>'limit','require'=>false),
                'page'=>array('name'=>'page','require'=>false)
            ),
            'domainMovieList' => array(
                'domain'=>array('name' => 'domain', 'require' => false),
                'limit'=>array('name'=>'limit','require'=>false),
                'page'=>array('name'=>'page','require'=>false)
            ),
            'getMovieByPid' => array(
                'pid'=>array('name'=>'pid','require'=>true),
                'limit'=>array('name'=>'limit','require'=>false),
                'page'=>array('name'=>'page','require'=>false)
            ),
            'setDomains'=>array(),
            'getMovieByYear' => array(
                'pid'=>array('name'=>'pid','require'=>true),
                'year'=>array('name'=>'year','require'=>true),
                'limit'=>array('name'=>'limit','require'=>false),
                'page'=>array('name'=>'page','require'=>false)
            ),
            'getLikeList' => array(),
            'getMovieBySourceId' => array(
                'cid'=>array('name'=>'source_id','require'=>true),
                'limit'=>array('name'=>'limit','require'=>false),
                'page'=>array('name'=>'page','require'=>false)
            ),
            'update' => array(
                'id' => array('name' => 'id', 'require' => false),
                'title'=>array('name'=> 'title','require'=>true),
                'cate_id'=>array('name'=> 'cate_id', 'require'=>true),
                'to_star'=>array('name'=> 'to_star', 'require'=>true),
                'tag'=>array('name'=> 'tag', 'require'=>false),
                'director'=>array('name'=> 'director', 'require'=>true),
                'language'=>array('name'=> 'language', 'require'=>true),
                'region'=>array('name'=> 'region', 'require'=>true),
                'desc'=>array('name'=> 'desc', 'require'=>true),
                'introduce'=>array('name'=> 'introduce', 'require'=>true),
                'score'=>array('name'=> 'score', 'require'=>true),
            ),
            'delete'=> array(
                'id'=> array('name'=>'id','require'=>true)
            )
        );
    }
    /**
     * 获取电影列表
     * @desc 用于后端获取电影列表
     */
    public function getList() {
        $domain = new MovieListDomain();
        $res = $domain->getList($this->limit,$this->page);
        return $res;
    }
    /**
     * 获取猜你喜欢列表
     * @desc 用于获取猜你喜欢列表
     */
    public function getLikeList() {
        $domain = new MovieListDomain();
        $res = $domain->getLikeList();
        return $res;
    }
    /**
     * 获取首页电影列表
     * @desc 用于获取首页电影列表
     */
    public function getHome() {
        $domain = new MovieListDomain();
        $res = $domain->getHome();
        return $res;
    }
    /**
     * 通过source_id电影详情
     * @desc 用于通过source_id电影详情
     */
    public function getMovieInfo() {
        $domain = new MovieListDomain();
        $res = $domain->getMovieInfo($this->source_id);
        return $res;
    }
    /**
     * 获取年份下所有电影
     * @desc 获取年份下所有电影
     */
    public function getMovieByYear() {
        $domain = new MovieListDomain();
        $res = $domain->getMovieByYear($this->pid,$this->year,$this->limit,$this->page);
        return $res;
    }
    /**
     * 搜索电影列表
     * @desc 用于前端搜索电影列表
     */
    public function searchMovieList() {
        $domain = new MovieListDomain();
        $res = $domain->searchMovieList($this->title,$this->limit,$this->page);
        return $res;
    }
    /**
     * 按照网站名搜索电影列表
     * @desc 按照网站名搜索电影列表
     */
    public function domainMovieList() {
        $domain = new MovieListDomain();
        $res = $domain->domainMovieList($this->domain,$this->limit,$this->page);
        return $res;
    }
    /**
     * 获取子级分类下所有列表
     * @desc 获取子级分类下所有列表
     */
    public function getMovieBySourceId() {
        $domain = new MovieListDomain();
        $res = $domain->getMovieBySourceId($this->cid,$this->limit,$this->page);
        return $res;
    }
    /**
     * 获取父级分类下所有列表
     * @desc 获取父级分类下所有列表
     */
    public function getMovieByPid() {
        $domain = new MovieListDomain();
        $res = $domain->getMovieByPid($this->pid,$this->limit,$this->page);
        return $res;
    }
    /**
     * 搜索电影列表
     * @desc 用于后端搜索电影列表
     */
    public function searchList() {
        $domain = new MovieListDomain();
        $res = $domain->searchList($this->title,$this->limit,$this->page);
        return $res;
    }
    /**
     * 更新或添加电影
     * @desc 有id则是更新无id则是添加
     */
    public function update() {
        $domain = new MovieListDomain();
        $data=array(
            'title'=>$this->title,
            'cate_id'=>$this->cate_id,
            'tag'=>$this->tag,
            'director'=>$this->director,
            'language'=>$this->language,
            'region'=>$this->region,
            'score'=>$this->score,
            'update_time'=>date('Y-m-d H:i:s',time())
        );
        $res = $domain->update($this->id,$data);
        return $res;
    }
    /**
     * 删除电影
     * @desc 删除电影
     */
    public function delete() {
        $domain = new MovieListDomain();
        $res = $domain->delete($this->id);
        return array($res);
    }
    /**
     * 设置电影domain
     * @desc 设置电影domain
     */
    public function setDomains() {
       $domain = new MovieListDomain();
       $res = $domain->setDomains();
       return $res;
    }

}
